package org.pr.ddddesigner.interfaces.rest;

import com.lion.commons.result.CommonResult;
import com.xw.framework.rest.AbstractBaseHandler;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.validation.Valid;
import org.pr.ddddesigner.application.UserApplicationService;
import org.pr.ddddesigner.interfaces.dto.CreateUser;
import org.pr.ddddesigner.interfaces.dto.UserInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Mono;


/**
 * @description:
 * @projectName:DDD-Designer
 * @see:org.pr.ddddesigner.interfaces.rest
 * @author:LXC
 * @createTime:2024/4/19 13:41
 * @version:1.0
 */
@RestController
@RequestMapping("${app.context-path}/user")
public class UserResource extends AbstractBaseHandler {

    @Value("${app.context-path}") public  String appContextPath;

    private final UserApplicationService service;

    @Autowired
    public UserResource(UserApplicationService service) {
        this.service = service;
    }

    @Operation(summary = "新增用户", description = "新增用户") @PutMapping("/addUser")
    public Mono<CommonResult<UserInfo>> addUser(@Valid @RequestBody CreateUser req) {
        return result(service.createUser(req));
    }

    @GetMapping(value = "/getUserInfo")
    public String getUserInfo(@RequestBody Mono<CreateUser> req){
        return "hello";
    }
}
